﻿using HZY.Host.Admin.ApplicationServices.Systems;
using HZY.Host.Admin.Models.Dtos.Systems;

namespace HZY.Host.Admin.Controllers.Systems;

[ControllerDescriptor(MenuId = "42", DisplayName = "附件管理")]
public class SysFileController(IServiceProvider serviceProvider)
    : AdminControllerBase<SysFileService, SysFile, Guid, SysFileSearchDto, SysFile>(serviceProvider)
{
    /// <summary>
    /// 上传文件
    /// </summary>
    /// <param name="uploadFileSaveDto"></param>
    /// <param name="file"></param>
    /// <returns></returns>
    [ActionDescriptor(DisplayName = "上传文件")]
    [HttpPost]
    public async Task<SysFileResultDto> UploadFileAsync([FromForm] UploadFileSaveDto uploadFileSaveDto, IFormFile file)
    {
        return await Service.UploadFileAsync(uploadFileSaveDto, file);
    }

    /// <summary>
    /// 下载文件
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [ActionDescriptor(DisplayName = "下载文件")]
    [HttpGet("{id:guid}")]
    public Task<IActionResult> DownloadFileAsync([FromRoute] Guid id)
    {
        return Service.DownloadFileAsync(id);
    }
}